<?php
session_start();
if(!isset($_SESSION['Name'])){
header('Location: index.php');
}
if(isset($_GET['height'])&&isset($_GET['weight'])){
$err = array();
	unset($err);
	    	
	if (!is_numeric($_GET['height']) || $_GET['height']<=0){
		$err['height'] = 'Špatná výška.';
	}
	else{$_SESSION['Height']=$_GET['height'];}

	    	
	if (!is_numeric($_GET['weight']) || $_GET['weight']<=0){
		$err['weight'] = 'Špatná váha.';
	}
	else{$_SESSION['Weight']=$_GET['weight'];}
	
	if (!is_numeric($_GET['beers']) || $_GET['beers']<=0){
		$err['beers'] = 'Špatně zadaný počet piv.';
	}
	else{$_SESSION['Beers']=$_GET['beers'];}
	if(!isset($err)){

	header('Location: step3.php');}
}
include("Design.php");
Top();
?>
<form action="step2.php" method="get">
		
	<br/><br/>
	<label for="weight"> Váha <br/>(v kilogramech)</label>
	<input type="text" id="weight" name="weight" value="<?php echo $_SESSION['Weight'];?>">
    
	<br/><br/>
	<label for="height"> Výška<br/>(v centimetrech)</label>
	<input type="text" id="height" name="height" value="<?php echo $_SESSION['Height'];?>">
	
	<br/><br/>
	<label for="beers"> Počet piv</label>
	<input type="text" id="beers" name="beers" value="<?php echo $_SESSION['Beers'];?>">
	<input type="submit" value="Dalsi">
</form>

<?php
foreach ($err as $current){
			echo "<div class='WrongValue'>" . $current . "</div><br/>";
		}
		Bottom();
?>